{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
    <h3 class="pb-3">新建企业信息</h3>
    <table class="layui-table layui-table-form">
        <tr>
            <td class="layui-td-gray-2">企业名称<font>*</font></td>
            <td style="width: 400px"><input type="text" name="name" lay-verify="required" lay-reqText="请完善企业名称" value=""
                       autocomplete="off" placeholder="请输入企业名称" class="layui-input"></td>
            <td class="layui-td-gray-2">营业状态</td>
            <td>
                <select name="status">
                    <option value="在营/存续">在营/存续</option>
                    <option value="迁入/迁出">迁入/迁出</option>
                    <option value="吊销/撤销">吊销/撤销</option>
                    <option value="注销">注销</option>
                    <option value="停业">停业</option>
                    <option value="其他">其他</option>
                </select>
            </td>
            <td class="layui-td-gray-2">法定代表人</td>
            <td><input type="text" name="faren" value="" autocomplete="off" placeholder="请输入法定代表人"
                       class="layui-input"></td>
        </tr>
        <tr>
            <td class="layui-td-gray">省市区<font>*</font></td>
            <td colspan="4" style="display: flex;">
                <select name="province_id" lay-filter="province" id="province" lay-verify="required">
                    <option value="">选择省份</option>
                    {volist name="$cityList" id="vo"}
                    <option value="{$vo.id}">{$vo.name}</option>
                    {/volist}
                </select>
                <select name="city_id" lay-filter="city" id="city" lay-verify="required">
                    <option value="">选择城市</option>
                </select>
                <select name="district_id" lay-filter="district" id="district" lay-verify="required">
                    <option value="">请选择县区</option>
                </select>
            </td>
            <td class="layui-td-gray-2">注册地址</td>
            <td><input type="text" name="address" value="" autocomplete="off" placeholder="请输入注册地址"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">成立日期</td>
            <td>
                <input type="text" class="layui-input" id="start_time" readonly placeholder="成立日期" name="riqi">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">统一社会信用代码</td>
            <td><input type="text" name="daima" value="" autocomplete="off" placeholder="请输入统一社会信用代码"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">更多电话</td>
            <td><input type="text" name="mobile_more" value="" autocomplete="off" placeholder="请输入更多电话"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">企业类型</td>
            <td>
                <select name="leixing">
                    {volist name="$qiCate" id="v5"}
                    <option value="{$v5.title}">{$v5.title}</option>
                    {/volist}
                </select>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">参保人数</td>
            <td><input type="text" name="canbao" value="" autocomplete="off" placeholder="请输入参保人数"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">招聘情况</td>
            <td><input type="text" name="zhaopin" value="" autocomplete="off" placeholder="请输入招聘情况"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">网络推广</td>
            <td><input type="text" name="wangluo" value="" autocomplete="off" placeholder="请输入网络推广"
                       class="layui-input"></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">网站域名</td>
            <td><input type="text" name="yuming" value="" autocomplete="off" placeholder="请输入网站域名"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">商标</td>
            <td><input type="text" name="shangbiao" value="" autocomplete="off" placeholder="请输入商标"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">专利</td>
            <td><input type="text" name="zhuanli" value="" autocomplete="off" placeholder="请输入专利"
                       class="layui-input"></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">招投标</td>
            <td><input type="text" name="zhaobiao" value="" autocomplete="off" placeholder="请输入招投标"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">公众号</td>
            <td><input type="text" name="gongzhong" value="" autocomplete="off" placeholder="请输入公众号"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">有效手机号</td>
            <td><input type="text" name="mobile" value="" autocomplete="off" placeholder="请输入有效手机号"
                       class="layui-input"></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">邮箱</td>
            <td><input type="text" name="emails" value="" autocomplete="off" placeholder="请输入邮箱"
                       class="layui-input"></td>
            <td class="layui-td-gray-2">qq号码</td>
            <td><input type="text" name="qq" value="" autocomplete="off" placeholder="请输入qq号码" class="layui-input">
            </td>
            <td class="layui-td-gray-2">注册资本</td>
            <td><input type="text" name="zhuce" value="" autocomplete="off" placeholder="请输入注册资本"
                       class="layui-input"></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">行业分类</td>
            <td style="display: flex">
                <select name="cate_one" id="cate_one" lay-filter="selCate" lay-reqText="请选择一级分类">
                    <option value="">请选择一级分类</option>
                    {volist name="cate" id="v4"}
                    <option value="{$v4.id}">{$v4.title}</option>
                    {/volist}
                </select>
                <select name="cate_two" id="cate_two" lay-reqText="请选择二级分类">
                    <option value="">请选择二级分类</option>
                </select>
            </td>
            <td class="layui-td-gray-2">SVIP定制分类</td>
            <td>
                <select name="news_file_id">
                    <option value="">请选择</option>
                    {volist name="$svipCate" id="vv1"}
                    <option value="{$vv1.id}">{$vv1.title}</option>
                    {/volist}
                </select>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">经营范围</td>
            <td colspan="5">
                <textarea name="jingying" class="layui-textarea"></textarea>
            </td>
        </tr>
    </table>
    <div class="pt-3">
        <input type="hidden" name="id" value="0"/>
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    var moduleInit = ['tool'];

    function gouguInit() {
        var form = layui.form, tool = layui.tool;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var element = layui.element;
        laydate.render({
            elem: '#start_time',
            type: 'date'
        });

        form.on('select(selCate)',function(data){
            let cate_id = data.value
            tool.get("/admin/news/getCate", {id:cate_id}, function(res){
                let data = res.data
                let _html = '<option value="">请选择二级分类</option>';
                if (data.length > 0) {
                    for (var i=0;i<data.length;i++) {
                        _html += '<option value="'+data[i].id+'">'+data[i].title+'</option>';
                    }
                }
                $('#cate_two').html(_html);
                form.render();
            });
        });
        //监听省份
        form.on('select(province)',function(data){
            let cate_id = data.value
            $.ajax({
                url:'{:url("news/getcity")}',
                data:{id:cate_id},
                type:"get",
                success:function(res) {
                    console.log(res)
                    let data = res.data.data
                    let _html = '<option value="">请选择城市</option>';
                    if (data.length > 0) {
                        for (var i=0;i<data.length;i++) {
                            _html += '<option value="'+data[i].id+'">'+data[i].name+'</option>';
                        }
                    }
                    $('#city').html(_html);
                    let _htmls = '<option value="">请选择县区</option>';
                    $('#district').html(_htmls);
                    form.render();
                }
            });
        });

        //监听市
        form.on('select(city)',function(data){
            let cate_id = data.value
            $.ajax({
                url:'{:url("news/getdis")}',
                data:{id:cate_id},
                type:"get",
                success:function(res) {
                    let data = res.data.data
                    let _html = '<option value="">请选择县区</option>';
                    if (data.length > 0) {
                        for (var i=0;i<data.length;i++) {
                            _html += '<option value="'+data[i].id+'">'+data[i].name+'</option>';
                        }
                    }
                    $('#district').html(_html);
                    form.render();
                }
            });
        });
        //监听提交
        form.on('submit(webform)', function (data) {

            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    tool.sideClose(1000);
                }
            }
            tool.post("/admin/news/add", data.field, callback);
            return false;
        });
    }

</script>
{/block}
<!-- /脚本 -->